﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Statistics 的摘要说明
/// 统计的一些函数，以及数据获取处理
/// </summary>
public class Statistics
{
	public Statistics()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    /// <summary>
    /// 得到emId考试的emRankName的等级
    /// </summary>
    /// <param name="emId"></param>
    /// <param name="emRankName"></param>
    /// <returns></returns>
    public static DataTable getApplyFinish(string timeID,string emRankName,string applyState,string studFrom)
    {
        string cmdText = @"select count(*) as Count 
                             from ApplyInfo as a,ExamTime as b
                            where  a.EmID = b.EmID and a.EmYear = b.EmYear and a.EmNum = b.EmNum and b.TimeID = @TimeID
                                   And EmRankName=@emRankName and ApplyState=@applyState and StudFrom=@studFrom";
        SqlParameter[] parms = new SqlParameter[]{
            new SqlParameter("@TimeID",SqlDbType.Int),
            new SqlParameter("@emRankName",SqlDbType.NVarChar,20),
            new SqlParameter("@applyState",SqlDbType.Int),
            new SqlParameter("@studFrom",SqlDbType.NVarChar,20)
        };
        parms[0].Value = timeID;
        parms[1].Value = emRankName;
        parms[2].Value = applyState;
        parms[3].Value = studFrom;
        return (DataTable)Dbase.GetDataTable(CommandType.Text, cmdText, parms);

    }

    public static DataTable getAllExamName(string timeID)
    {
        string cmdText = @"select distinct EmRankName 
                             from ApplyInfo as a,ExamTime as b 
                            where a.EmID = b.EmID and a.EmYear = b.EmYear and a.EmNum = b.EmNum and b.TimeID = @TimeID ";
        SqlParameter[] parms = new SqlParameter[]{
            new SqlParameter("@TimeID",SqlDbType.Int)
        };
        parms[0].Value = timeID.Trim();
        return (DataTable)Dbase.GetDataTable(CommandType.Text, cmdText, parms);
    }

    public static DataTable getSchoolName(string timeID)
    {
        string cmdText = @"select distinct StudFrom 
                             from ApplyInfo as a,ExamTime as b 
                            where a.EmID = b.EmID and a.EmYear = b.EmYear and a.EmNum = b.EmNum and b.TimeID = @TimeID ";
        SqlParameter[] parms = new SqlParameter[]{
            new SqlParameter("@TimeID",SqlDbType.Int)
        };
        parms[0].Value = timeID.Trim();
        return (DataTable)Dbase.GetDataTable(CommandType.Text, cmdText, parms);
    }


}